package cz.muni.fi.pa165.sportclubmanager.dto;

import cz.muni.fi.pa165.sportclubmanager.entity.Player;

/**
 *
 * @author Michal Prokeš, 72758
 */
public class PlayerDTOMapping {
    /**
     * Map PlayerDTO to Player entity
     * @param dto PlayerDTO object
     * @return Player entity
     */
     public static Player toEntity(PlayerDTO dto) {
        if(dto==null) { return null; }
        
        Player entity = new Player();
        
        entity.setId(dto.getId());
        entity.setBirthDate(dto.getBirthDate());
        entity.setFirstName(dto.getFirstName());
        entity.setLastName(dto.getLastName());
        entity.setHeight(dto.getHeight());
        entity.setWeight(dto.getWeight());        
        
        return entity;
    }
     
     /**
     * Map Player to PlayerDTO 
     * @param entity Player object
     * @return PlayerDTO with all attributes
     */
     public static PlayerDTO toDto(Player entity) {
        if(entity==null) { return null; }
        
        PlayerDTO dto = new PlayerDTO();
        
        dto.setId(entity.getId());
        dto.setBirthDate(entity.getBirthDate());
        dto.setFirstName(entity.getFirstName());
        dto.setLastName(entity.getLastName());
        dto.setHeight(entity.getHeight());
        dto.setWeight(entity.getWeight());        
        
        return dto;
    }
   
            
    
}
